package com.guodi.model.controller;

import com.guodi.core.boot.ctrl.BaseController;
import com.guodi.core.tool.api.R;
import com.guodi.model.service.IIdtIndicatorsCountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

/**
 * @描述:数据看板-数据汇聚
 * @作者: lzy
 * @日期: 2023/6/12 15:13
 **/
@RestController
@RequestMapping("/IdtIndicatorsCount")
@Api(value = "API - IdtIndicatorsCountController", description = "数据看板-指标统计控制类")
public class IdtIndicatorsCountController extends BaseController {

    @Resource
    private IIdtIndicatorsCountService iIdtIndicatorsCountService;


    /**
     * @描述: 获取指标体系台账（包含值）
     * @入参:
     * @出参:
     * @作者: lzy
     * @日期: 2023/6/2 17:37
     **/
    @PostMapping("/getIdtIndicatorsVals")
    @ApiOperation(value = "获取指标体系台账（包含值）")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "divisionCode", value = "行政区划编码", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "year", value = "年份", dataType = "string", required = true, paramType = "query")
    })
    public R getIdtIndicatorsVals(String divisionCode, String year){
        if(StringUtils.isBlank(divisionCode)){
            return R.fail("行政区划必传");
        }
        if(StringUtils.isBlank(year)){
            return R.fail("年份必传");
        }
        R r = iIdtIndicatorsCountService.getIdtIndicatorsVals(divisionCode,year);
        return r;
    }

    /**
     * @描述: 导出指标体系台账
     * @入参:
     * @出参:
     * @作者: lzy
     * @日期: 2023/6/7 9:47
     **/
    @RequestMapping("/exportIdtIndicatorsVals")
    @ApiOperation(value = "导出指标体系台账（包含值）")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "divisionCode", value = "行政区划编码", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "year", value = "年份", dataType = "string", required = true, paramType = "query")
    })
    public void exportIdtIndicatorsVals(String divisionCode, String year, HttpServletResponse response) throws Exception{
        iIdtIndicatorsCountService.exportIdtIndicatorsVals(divisionCode,year,response);

    }


    /**
     * @描述: 获取指标数据来源台账
     * @入参:
     * @出参:
     * @作者: lzy
     * @日期: 2023/6/2 17:37
     **/
    @PostMapping("/getDataSourceList")
    @ApiOperation(value = "获取指标数据来源台账")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "divisionCode", value = "行政区划编码", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "year", value = "年份", dataType = "string", required = true, paramType = "query")
    })
    public R getDataSourceList(String divisionCode, String year){
        if(StringUtils.isBlank(divisionCode)){
            return R.fail("行政区划必传");
        }
        if(StringUtils.isBlank(year)){
            return R.fail("年份必传");
        }
        R r = iIdtIndicatorsCountService.getDataSourceList(divisionCode,year);
        return r;
    }

    /**
     * @描述: 导出指标数据来源台账
     * @入参:
     * @出参:
     * @作者: lzy
     * @日期: 2023/6/7 11:50
     **/
    @RequestMapping("/exportDataSourceList")
    @ApiOperation(value = "导出指标数据来源台账")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "divisionCode", value = "行政区划编码", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "year", value = "年份", dataType = "string", required = true, paramType = "query")
    })
    public void exportDataSourceList(String divisionCode, String year, HttpServletResponse response) throws Exception{
        iIdtIndicatorsCountService.exportDataSourceList(divisionCode,year,response);
    }

    /**
     * @描述: 获取责任单位台账
     * @入参:
     * @出参:
     * @作者: lzy
     * @日期: 2023/6/6 15:14
     **/
    @PostMapping("/getDutyCompanyList")
    @ApiOperation(value = "获取责任单位台账")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "divisionCode", value = "行政区划编码", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "year", value = "年份", dataType = "string", required = true, paramType = "query")
    })
    public R getDutyCompanyList(String divisionCode, String year){
        if(StringUtils.isBlank(divisionCode)){
            return R.fail("行政区划必传");
        }
        if(StringUtils.isBlank(year)){
            return R.fail("年份必传");
        }
        R r = iIdtIndicatorsCountService.getDutyCompanyList(divisionCode,year);
        return r;
    }

    /**
     * @描述: 导出指标责任单位台账
     * @入参:
     * @出参:
     * @作者: lzy
     * @日期: 2023/6/7 14:49
     **/
    @RequestMapping("/exportDutyCompanyList")
    @ApiOperation(value = "导出指标责任单位台账")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "divisionCode", value = "行政区划编码", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "year", value = "年份", dataType = "string", required = true, paramType = "query")
    })
    public void exportDutyCompanyList(String divisionCode, String year, HttpServletResponse response) throws Exception{
        iIdtIndicatorsCountService.exportDutyCompanyList(divisionCode,year,response);
    }

    /**
     * @描述: 获取体检评估指标体系
     * @入参:
     * @出参:
     * @作者: lzy
     * @日期: 2023/6/7 17:01
     **/
    @RequestMapping("/getIndicatorsTreeList")
    @ApiOperation(value = "获取体检评估指标体系")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "divisionCode", value = "行政区划编码", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "year", value = "年份", dataType = "string", required = true, paramType = "query"),
            @ApiImplicitParam(name = "keyword", value = "关键字", dataType = "string", required = false, paramType = "query"),
            @ApiImplicitParam(name = "idtType", value = "指标类型", dataType = "string", required = false, paramType = "query")
    })
    public R getIndicatorsTreeList(String divisionCode, String year, String keyword, String idtType){

        R r = this.iIdtIndicatorsCountService.getIndicatorsTreeList(divisionCode,year,keyword,idtType);
        return r;
    }

    /**
     * @描述: 导出体检评估指标体系
     * @入参:
     * @出参:
     * @作者: lzy
     * @日期: 2023/6/9 10:51
     **/
    @RequestMapping("/exportIndicatorsTreeList")
    @ApiOperation(value = "导出体检评估指标体系")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "divisionCode", value = "行政区划编码", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "year", value = "年份", dataType = "string", required = true, paramType = "query"),
            @ApiImplicitParam(name = "keyword", value = "关键字", dataType = "string", required = false, paramType = "query"),
            @ApiImplicitParam(name = "idtType", value = "指标类型", dataType = "string", required = false, paramType = "query"),
            @ApiImplicitParam(name = "parentName", value = "维度名称", dataType = "string", required = false, paramType = "query")
    })
    public void exportIndicatorsTreeList(String divisionCode, String year, String keyword, String idtType, String parentName, HttpServletResponse response) throws Exception{
        this.iIdtIndicatorsCountService.exportIndicatorsTreeList(divisionCode,year,keyword,idtType,parentName,response);
    }


}
